using Game.XH;
using UnityEngine;

namespace Game.Component.Character
{
	public class Hair : CharacterComponent
	{
		public enum Dir
		{
			Front = 0,
			Back = 1
		}

		private const int FRONT_Z = -4;

		private const int BACK_Z = 14;

		private Dir dir;

		public int hairId;

		public Color32 color;

		public Vector3 originalScale;

		public float originalAngle;

		public float hairHeight;

		public Hair(Transform trans, Dir dir)
			: base(trans)
		{
			if (dir == Dir.Front)
			{
				trans.SetLocalZ(-4E-05f);
			}
			else
			{
				trans.SetLocalZ(0.00013999999f);
			}
			originalScale = trans.localScale;
			originalAngle = trans.localEulerAngles.z;
		}

		public void SetHair(int id, Transform copy)
		{
			if (hairId != id)
			{
				hairId = id;
				ChangeSprite(copy);
				hairHeight = spriteRenderer.transform.localPosition.y + spriteRenderer.bounds.size.y / 2f;
			}
		}

		public void SetHairColor(Color32 color)
		{
			this.color = color;
			spriteRenderer.color = color;
		}

		public void SetHairVisible(bool val)
		{
			if (transform.gameObject.activeSelf != val)
			{
				transform.gameObject.SetActive(val);
			}
		}

		public bool IsVisibled()
		{
			return transform.gameObject.activeSelf;
		}
	}
}
